﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Media;

namespace Zero.UControl.Component.ScreenCut.Base
{
    public class DrawRectangleCommand : IDrawCommand
    {
        private Canvas _canvas;
        private Rectangle _rectangle;

        public DrawRectangleCommand(Canvas canvas, Rect bounds, Brush stroke, double thickness)
        {
            _canvas = canvas;
            _rectangle = new Rectangle
            {
                Stroke = stroke,
                StrokeThickness = thickness,
                Width = bounds.Width,
                Height = bounds.Height
            };
            Canvas.SetLeft(_rectangle, bounds.X);
            Canvas.SetTop(_rectangle, bounds.Y);
        }

        public void Execute()
        {
            _canvas.Children.Add(_rectangle);
        }

        public void Undo()
        {
            _canvas.Children.Remove(_rectangle);
        }
    }

}
